package com.cyk.like_test.infra;

import com.cyk.like_test.model.constants.MqConst;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {

    @Bean
    public DirectExchange statExchange() {
        return new DirectExchange(MqConst.STAT_DIRECT, false, false);
    }

    @Bean
    public Queue likeMySQLQueue() {
        return new Queue(MqConst.LIKE_MySQL_QUEUE, false);
    }

    @Bean
    public Queue likeMongoQueue() {
        return new Queue(MqConst.LIKE_MONGO_QUEUE, false);
    }

    @Bean
    public Queue syncLikeMySQLQueue() {
        return new Queue(MqConst.SYNC_LIKE_MYSQL_QUEUE, false);
    }

    @Bean
    public Binding likeMySQLBinding() {
        return BindingBuilder
                .bind(likeMySQLQueue())
                .to(statExchange())
                .with(MqConst.LIKE_MySQL_QUEUE);
    }

    @Bean
    public Binding likeMongoBinding() {
        return BindingBuilder
                .bind(likeMongoQueue())
                .to(statExchange())
                .with(MqConst.LIKE_MONGO_QUEUE);
    }

    @Bean

    public Binding syncLikeMySQLBinding() {
        return BindingBuilder
                .bind(syncLikeMySQLQueue())
                .to(statExchange())
                .with(MqConst.SYNC_LIKE_MYSQL_QUEUE);
    }


}
